package com.jfs.constant;

/**
 * @Description sdp协议语法模板
 * @E-mail cwm3412638@163.com
 * @Author cwm
 * @Date 2022-08-23
 */
public interface SdpConstant {
    String MEDIA_SERVER_IP = "{mediaServerIp}";
    String SSRC = "{ssrc}";

    String SIP_ID = "{sipId}";
    String MEDIA_PORT = "{mediaPort}";
    /**
     * 换行符
     */
    String LINE_FEED = "\r\n";
    /**
     * 请求视频流基础sdp协议模板
     */
    String INVITE_BASE = "v=0" + LINE_FEED
            + "o=" + SIP_ID + " 0 0 IN IP4 " + MEDIA_SERVER_IP + LINE_FEED
            + "s=Play" + LINE_FEED
            + "c=IN IP4 " + MEDIA_SERVER_IP + LINE_FEED
            + "t=0 0" + LINE_FEED;

    /**
     * 请求视频流基础sdp协议结束模板
     */
    String INVITE_BASE_END = "y=" + SSRC + LINE_FEED;
    /**
     * SDP协议开启基础协议模板
     */
    String SDP_ENABLE_BASE = "a=recvonly" + LINE_FEED
            + "a=rtpmap:96 PS/90000" + LINE_FEED
            + "a=fmtp:126 profile-level-id=42e01e" + LINE_FEED
            + "a=rtpmap:126 H264/90000" + LINE_FEED
            + "a=rtpmap:125 H264S/90000" + LINE_FEED
            + "a=fmtp:125 profile-level-id=42e01e" + LINE_FEED
            + "a=rtpmap:99 MP4V-ES/90000" + LINE_FEED
            + "a=fmtp:99 profile-level-id=3" + LINE_FEED
            + "a=rtpmap:98 H264/90000" + LINE_FEED
            + "a=rtpmap:97 MPEG4/90000" + LINE_FEED;

    /**
     * SDP协议开启UDP协议模板
     */
    String SDP_ENABLE_UDP = INVITE_BASE
            + "m=video " + MEDIA_PORT + " RTP/AVP 96 126 125 99 34 98 97" + LINE_FEED
            + SDP_ENABLE_BASE
            + INVITE_BASE_END;

    /**
     * SDP协议开启tcp被动模式协议模板
     */
    String SDP_ENABLE_TCP_PASSIVE = INVITE_BASE
            + "m=video " + MEDIA_PORT + " TCP/RTP/AVP 96 126 125 99 34 98 97" + LINE_FEED
            + SDP_ENABLE_BASE
            + "a=setup:passive" + LINE_FEED
            + "a=connection:new" + LINE_FEED
            + INVITE_BASE_END;
    /**
     * SDP协议开启tcp主动模式协议模板
     */
    String SDP_ENABLE_TCP_ACTIVE = INVITE_BASE
            + "m=video " + MEDIA_PORT + " TCP/RTP/AVP 96 126 125 99 34 98 97" + LINE_FEED
            + SDP_ENABLE_BASE
            + "a=setup:active" + LINE_FEED
            + "a=connection:new" + LINE_FEED
            + INVITE_BASE_END;

    /**
     * SDP协议关闭基础协议模板
     */
    String SDP_DISABLE_BASE = "a=rtpmap:96 PS/90000" + LINE_FEED
            + "a=rtpmap:97 MPEG4/90000" + LINE_FEED
            + "a=rtpmap:98 H264/90000" + LINE_FEED
            + "a=recvonly" + LINE_FEED;

    /**
     * SDP协议关闭UDP协议模板
     */
    String SDP_DISABLE_UDP = INVITE_BASE
            + "m=video " + MEDIA_PORT + " RTP/AVP 96 97 98" + LINE_FEED
            + SDP_DISABLE_BASE
            + INVITE_BASE_END;

    /**
     * SDP协议关闭tcp被动模式协议模板
     */
    String SDP_DISABLE_TCP_PASSIVE = INVITE_BASE
            + "m=video " + MEDIA_PORT + " TCP/RTP/AVP 96 98 97" + LINE_FEED
            + SDP_DISABLE_BASE
            + "a=setup:passive" + LINE_FEED
            + "a=connection:new" + LINE_FEED
            + INVITE_BASE_END;
    /**
     * SDP协议开启tcp主动模式协议模板
     */
    String SDP_DISABLE_TCP_ACTIVE = INVITE_BASE
            + "m=video " + MEDIA_PORT + " TCP/RTP/AVP 96 98 97" + LINE_FEED
            + SDP_DISABLE_BASE
            + "a=setup:active" + LINE_FEED
            + "a=connection:new" + LINE_FEED
            + INVITE_BASE_END;
}
